<?php

include('../confdb.php');

$con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

if(!$con) {

die ('Ошибка подключения: '.mysqli_connect_error());

} 

$otvet=array();
$query = "SELECT * FROM vistuplenie where vistuplenie_activno=1 order by vistuplenie_sort, idvistuplenie";

$result = mysqli_query($con, $query);

if($result){
    $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
    $otvet['success']=$row['idvistuplenie'] ?? '';
    $idphum = $row['phumse_idphumse'];
    $phum = "SELECT * FROM phumse WHERE idphumse = '$idphum'";
    $res = mysqli_query($con, $phum);
    $phumname = mysqli_fetch_array($res, MYSQLI_ASSOC);
    $phumse = $phumname['phumse_name'];
    $otvet['vistuplenie_pokaz']=$row['vistuplenie_pokaz'];
    $otvet['phumse'] = $phumse; 
    $otvet['idphumse'] = $idphum;
    $otvet['system'] = $row['vistuplenie_sys'];
}
echo json_encode($otvet);

mysqli_close($con);

?>

